// 抽象工厂
class MobilePhoneFactory {
  creatOS() {

  }
  creatHardWare() {
  }
}

class PiniaFadtory extends MobilePhoneFactory {
  creatOS() {
    return new AndroidOS()
  }
  creatHardWare() {
    return new QualcommHardWare()
  }
}



class OS {
  controlHardWare() {
    throw new Error('抽象方法')
  }
}
class AndroidOS extends OS {
  controlHardWare() {
    console.log('以安卓的方式操作硬件');
  }
}

class AppleOS extends OS {
  controlHardWare() {
    console.log('以苹果的方式操作硬件');
  }
}




class HardWare {
  operateByOrder() {
    throw new Error('抽象方法')
  }
}

class QualcommHardWare extends HardWare {
  operateByOrder() {
    console.log('用高通的方式运行系统');
  }
}

class MiHardWare extends HardWare {
  operateByOrder() {
    console.log('用小米的方式运行系统');
  }
}


const myPhone = new PiniaFadtory()
const myOS = myPhone.creatOS()
const myHard = myPhone.creatHardWare()
myOS.controlHardWare()
myHard.operateByOrder()

class OrangeFactory extends MobilePhoneFactory {
  creatOS() { }
  creatHardWare() { }
}